import { pubRequire, downFile } from '@utils/public'

const baseUrl = '/questionnaires'

// 问卷模板列表
export function templates(params, callBack, errBack) {
  return pubRequire('get', `${baseUrl}/templates`, params, callBack, errBack)
}

// 禁用问卷模板
export function disabled(id, obj, callbBack, errBack) {
  return pubRequire('put',`${baseUrl}/templates/${id}/disabled`, obj, callbBack, errBack)
}

// 启用问卷模板
export function enabled(id, obj, callbBack, errBack) {
  return pubRequire('put',`${baseUrl}/templates/${id}/enabled`, obj, callbBack, errBack)
}

// 问卷列表
export function questionnaires(params, callBack, errBack) {
  return pubRequire('get', `${baseUrl}`, params, callBack, errBack)
}

// 删除问卷
export function delQuestionnaires(id, callbBack, errBack) {
  return pubRequire('delete', `${baseUrl}/${id}`, '', callbBack, errBack)
}

// 结束问卷
export function endQuestionnaires(id, callbBack, errBack) {
  return pubRequire('delete', `${baseUrl}/${id}/end`, '', callbBack, errBack)
}

// 查看答卷数据
export function answersData(params, callBack, errBack) {
  return pubRequire('get', `${baseUrl}/${params.questionId}/answers`, params.query, callBack, errBack)
}

// 查看答卷数据--->导出功能
export function exportAnswersData(params, errBack) {
  return downFile('get', `${baseUrl}/${params.questionId}/export`, params.query, params.questionName, errBack)
}


// 课程-根据学院id,获取课程列表
export function courseList(obj, callbBack, errBack) {
  return pubRequire('get', `/courses`, obj, callbBack, errBack)
}

// 课程-根据课程id,获取获取期列表
export function stageList(courseId, callbBack, errBack) {
  return pubRequire('get', `/courses/${courseId}/stage`, '', callbBack, errBack)
}

// 新增问卷
export function addQuestionnaires(params, callBack, errBack) {
  return pubRequire('post', `${baseUrl}`, params, callBack, errBack)
}

// 问卷详情
export function questionnairesDetails(id, callbBack, errBack) {
  return pubRequire('get', `${baseUrl}/${id}/info`, {}, callbBack, errBack)
}

// 编辑问卷
export function editQuestionnaires(id, obj, callbBack, errBack) {
  return pubRequire('put',`${baseUrl}/${id}`, obj, callbBack, errBack)
}
